STACKITLB-1837 | add ALB certificates to provider#1296
STACKITLB-1837 | add ALB certificates to provider#1296david-mey-STACKIT wants to merge 17 commits intostackitcloud:mainfrom
Conversation
Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com>
289b525 to
f74a895
Compare
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
|
|
||
| subject { | ||
| common_name = "localhost" | ||
| organization = "Stackit Test" |
There was a problem hiding this comment.
| organization = "Stackit Test" | |
| organization = "STACKIT Test" |
| func (r *certDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { | ||
| descriptions := map[string]string{ | ||
| "main": "Certificates resource schema.", | ||
| "id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`name`.", |
There was a problem hiding this comment.
| "id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`name`.", | |
| "id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`cert_id`.", |
The id should always contain the attributes, which a required to call the GET endpoint.
| "id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`name`.", | ||
| "project_id": "STACKIT project ID to which the certificate is associated.", | ||
| "region": "The resource region (e.g. eu01). If not defined, the provider region is used.", | ||
| "cert-id": "The ID of the certificate.", |
There was a problem hiding this comment.
keep the map keys consistent in snake case, like the attributes itself
| "cert-id": "The ID of the certificate.", | |
| "cert_id": "The ID of the certificate.", |
| Computed: true, | ||
| }, | ||
| "cert_id": schema.StringAttribute{ | ||
| Description: descriptions["cert-id"], |
There was a problem hiding this comment.
| Description: descriptions["cert-id"], | |
| Description: descriptions["cert_id"], |
| Computed: true, | ||
| PlanModifiers: []planmodifier.String{ | ||
| stringplanmodifier.RequiresReplace(), | ||
| stringplanmodifier.UseStateForUnknown(), |
There was a problem hiding this comment.
UseStateForUnknown is not needed here and can potentially cause some issues, so it should be removed
| stringplanmodifier.UseStateForUnknown(), |
| ConfigVariables: testConfigVarsMax, | ||
| Config: testutil.CertProviderConfig() + resourceMaxConfig, | ||
| Check: resource.ComposeAggregateTestCheckFunc( | ||
| // Load balancer instance resource |
| resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "public_key"), | ||
| resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "private_key"), |
There was a problem hiding this comment.
you can do here the same check mentioned above
|
|
||
| "github.com/hashicorp/terraform-plugin-framework/diag" | ||
| "github.com/stackitcloud/stackit-sdk-go/core/config" | ||
| certSdk "github.com/stackitcloud/stackit-sdk-go/services/certificates" |
There was a problem hiding this comment.
| certSdk "github.com/stackitcloud/stackit-sdk-go/services/certificates" | |
| certSdk "github.com/stackitcloud/stackit-sdk-go/services/certificates/v2api" |
| } | ||
| return fmt.Sprintf(` | ||
| provider "stackit" { | ||
| cart_custom_endpoint = "%s" |
There was a problem hiding this comment.
| cart_custom_endpoint = "%s" | |
| alb_certificates_custom_endpoint = "%s" |
| if providerData.ALBCustomEndpoint != "" { | ||
| apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCustomEndpoint)) | ||
| } |
There was a problem hiding this comment.
| if providerData.ALBCustomEndpoint != "" { | |
| apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCustomEndpoint)) | |
| } | |
| if providerData.ALBCertificatesCustomEndpoint != "" { | |
| apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCertificatesCustomEndpoint)) | |
| } |
Description
STACKITLB-1837
Add ALB TLS certificates provider (API: https://docs.api.stackit.cloud/documentation/certificates/version/v2)
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)